use actix_web::{get, post, web, HttpResponse, Responder};
use crate::models::response_object::ResponseObject;

#[get("/orders")]
async fn get_orders() -> impl Responder {
    HttpResponse::Ok().body("Get all orders")
}

#[post("/orders")]
async fn create_order() -> impl Responder {
    HttpResponse::Ok().body("Create a new order")
}

#[get("/state")]
async fn get_state() -> impl Responder {
    // 模拟一些数据
    let user_info = "用户信息";

    // 创建 ResponseObject 实例
    let response = ResponseObject::success_with_data(user_info.to_string());

    HttpResponse::Ok().json(response)
}

pub fn order_routes(cfg: &mut web::ServiceConfig) {
    cfg.service(get_orders);
    cfg.service(create_order);
    cfg.service(get_state);

}
